<%@ page import="org.apache.shiro.SecurityUtils"%>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css"
	href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.8.2/css/jquery.dataTables.css">
<!-- DataTables -->
<script type="text/javascript" charset="utf8"
	src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.8.2/jquery.dataTables.min.js"></script>
	
<link rel="stylesheet/less" type="text/css"
	href="${resource(dir:'less', file:'style.less') }">
<link rel="stylesheet"
	href="${resource(dir: 'css', file: 'common.css')}" type="text/css">
<script src="${resource(dir:'js', file: 'less-1.3.0.min.js') }"></script>
<script
	src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.0.3/bootstrap.min.js"></script>
<script src="${resource(dir:'js', file:'underscore-1.4.2.min.js') }"></script>
<script src="${resource(dir:'js', file:'backbone-0.9.2.min.js') }"></script>
<script src="${resource(dir:'js/app', file:'namespace.js') }"></script>
<script src="${resource(dir:'js', file:'jquery.placeholder.min.js') }"></script>
<link href="${resource(dir:'datepicker/css', file:'datepicker.css') }"
	rel="stylesheet">
<script
	src="${resource(dir:'datepicker/js', file:'bootstrap-datepicker.js') }"></script>

<title><g:layoutTitle /></title>
<calendar:resources lang="en" theme="tiger"/>
<g:layoutHead />
</head>
<body>
	<div class="updating-label hidden">
		<img src="${resource(dir:'less/images', file:'loader.gif') }" width=30 />
	</div>
	<div class="header">
		<div class="header-txt pull-left">
			<ul>
				<li class="dropdown"><a href="#" class="dropdown-toggle"
					data-toggle="dropdown"><h4>
							MasterCard <g:if test="${SecurityUtils.subject.session.getAttribute("current_user") }"><span class="caret"></span></g:if>
						</h4></a>
					<g:if test="${SecurityUtils.subject.session.getAttribute("current_user") }">
						<ul class="dropdown-menu">

							<g:if
								test="${SecurityUtils.subject.session.getAttribute("current_user_role") == 'admin' }">
								<li><a href="<g:createLink controller="dashboard" />">Dashboard</a></li>
								<li><a href="<g:createLink controller="deal" />">Manage
										Deals</a></li>
								<li><a href="<g:createLink controller="user" />">Manage
										Members</a></li>
								<li><a href="<g:createLink controller="merchant" />">Manage
										Merchants</a></li>
								<li><a href="<g:createLink controller="voucher" />">Manage
										Vouchers</a></li>
							</g:if>
							<g:else>
								<li><a href="<g:createLink controller="dashboard" />">Expense
										Overview</a></li>
				
								<li><a
									href="<g:createLink controller="report" />">Spending
										Report</a></li>
								<li class="dropdown"><a
									href="<g:createLink controller="redemption" action="searchvoucher" />">Rewards
										Redemption</a></li>
								<li><a
									href="<g:createLink controller="profile" action="index" />">Profile Setting</a></li>
							</g:else>
						</ul>
					</g:if>
				</li>
			</ul>
		</div>
		
		<div class="input-append pull-left left header-search hidden-phone">
			<form action="<g:createLink controller="deal" action="searchDeals" />"	method="get">
				<input class="span4" name="query" size="16" type="text"
					id="share-link-input" placeholder="Search Exclusive Deals...">
				<button class="btn" id="share-link" type="submit">Search</button>
			</form>
		</div>
		<g:if test="${SecurityUtils.subject.session.getAttribute("current_user") }">
		<div class="header-txt pull-right">
			<ul>
				<li class="dropdown"><a
					href="<g:createLink controller='auth' action='logout' />"
					class="dropdown-toggle" data-toggle="dropdown"
					style="margin-right: 10px;"><img
						src="${resource(dir:'images', file:'shut-down.png') }" /></a></li>
			</ul>
		</div>
		
		<div class="header-txt pull-right">
			<ul>
				<li><a href="<g:createLink controller="profile" action="index" />" id="login"><h4>
							${SecurityUtils.subject.session.getAttribute("current_user").name }
						</h4></a></li>
			</ul>
		</div>
		</g:if>
		<div style="clear: both;"></div>
	</div>

	<div class="content">
		<div class="main-content pull-left">
			<g:layoutBody />
		</div>
		
		<g:if test="${deals }">
		<div class="deals pull-right">
			<h2>Deals</h2>
			<g:each in="${deals}" var="deal">
				<div class="row">
					<div class="span1">
						<img src="${deal.imageUrl}" class="deal-img" />
					</div>
					<div class="span2">
						<div>
							<a href="#" onclick="window.open('${deal.detailUrl}', 'DealWebsite', 'location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes');"> ${deal.title }
							</a>
						</div>
						<div>$${deal.price }</div>
						<div>
							${deal.merchant.name }
						</div>
						<br />
					</div>
				</div>
				<hr>
			</g:each>
		</div>
		</g:if>
		<div style="clear: both;"></div>
		<p></p>
		<br />
		<div class="footer">
			<div class="pull-left">
				<b><g:link controller="auth" action="about">About MPEMS</g:link> | <g:link controller="auth" action="contactUs">Contact Us</g:link> | <g:link controller="auth" action="terms">Terms and Condition</g:link></b>
			</div>
		</div>
	</div>
</body>
</html>